﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities.Auditing;

namespace SanJ.FreeCare.Organizations
{
    /// <summary>
    /// 组织机构 及科室、院区、病区
    /// </summary>
    public class Organization : AuditedAggregateRoot<Guid>
    {

        /// <summary>
        /// 第三方/HIS编码
        /// </summary>
        public string ThirdId { get; private set; }

        /// <summary>
        /// Hierarchical Code of this organization unit.
        /// Example: "00001.00042.00005".
        /// This is a unique code for an OrganizationUnit.
        /// It's changeable if OU hierarchy is changed.
        /// </summary>
        public string Code { get; private set; }

        /// <summary>
        /// Active 在用 Inactive 停用
        /// </summary>
        public bool? Active { get; private set; }

        /// <summary>
        /// Kind of organization //住院，门急诊
        /// </summary>
        public string Type { get; private set; }

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; private set; }

        public Organization()
        {

        }

        public Organization(Guid id)
        {
            this.Id = id;
        }

        public Organization(string name, string thirdId, string code, string type)
        {
            this.Id = Guid.NewGuid();
            this.Name = name;
            this.ThirdId = thirdId;
            this.Code = code;
            this.Type = type;
            this.Active = true;
        }
        /// <summary>
        /// 修改组织机构名称
        /// </summary>
        /// <param name="name"></param>
        public void ModifyName(string name)
        {
            this.Name = name;
        }
        /// <summary>
        /// 第三方编码赋值
        /// </summary>
        /// <param name="associatedId"></param>
        public void SetAssociatedId(string thirdId)
        {
            this.ThirdId = thirdId;
        }
        /// <summary>
        /// 设置类型
        /// </summary>
        /// <param name="type"></param>
        public void SetType(string type)
        {
            this.Type = type;
        }
        /// <summary>
        /// 更改实体
        /// </summary>
        /// <param name="name"></param>
        /// <param name="associatedId"></param>
        /// <param name="type"></param>
        public void Update(string name, string thirdId, string type)
        {
            this.Name = name;
            this.ThirdId = thirdId;
            this.Type = type;
        }

        /// <summary>
        /// 设置无效
        /// </summary>
        public void SetIsActive(bool isActive)
        {
            this.Active = isActive;
        }
    }
}
